window.onload = function() {
    //获取系统当前时间
    function date() {
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var hour = "00" + date.getHours();
        hour = hour.substr(hour.length - 2);
        var minute = "00" + date.getMinutes();
        minute = minute.substr(minute.length - 2);
        var second = "00" + date.getSeconds();
        second = second.substr(second.length - 2);
        var week = date.getDay();
        switch (week) {
            case 1:
                week = "星期一 ";
                break;
            case 2:
                week = "星期二 ";
                break;
            case 3:
                week = "星期三 ";
                break;
            case 4:
                week = "星期四 ";
                break;
            case 5:
                week = "星期五 ";
                break;
            case 6:
                week = "星期六 ";
                break;
            case 0:
                week = "星期日 ";
                break;
            default:
                week = "";
                break;
        }
        document.getElementById("nowTime").innerHTML = year + "年" + month + "月" + day + "日" + " " + hour + ":" + minute + ":" + second + " " + week;
    }
    setInterval(date, 10);

    $('#user').change(function() {
        var val = $(this).val();
        checkUser(val);
    })
    $('#pass').change(function() {
        var val = $(this).val();
        checkPwd(val);
    })
    $("#phone").change(function() {
        var phone = $(this).val();
        checkregtel(phone);
    })

    $('#repass').change(function() {
        var val = $(this).val();
        reCheck(val);
    })


}

function checkUser(data) {
    var user = /^[a-zA-Z]\w{3,15}$/;
    if (user.test(data)) {
        $('.error_user').hide();
    } else {
        $('.error_user').show();
    }
}

function checkPwd(data) {
    var pwd = /^[a-zA-Z]\w{5,17}$/;
    if (pwd.test(data)) {
        $('.error_pass').hide();
    } else {
        $('.error_pass').show();
    }
}

function checkregtel(regtel) {
    var str = regtel;
    var Expression = /^13(\d{9})$|^15(\d{9})$|^189(\d{8})$/;
    var objExp = new RegExp(Expression);
    if (objExp.test(str) == true) {
        $('.error_phone').hide();
    } else {
        $('.error_phone').show();
    }
}

function reCheck(data) {
    if (data == $('#pass').val() && data != "") {
        $('.error_repass').hide();
    } else {
        $('.error_repass').show();
    }
}